package pl.myapp.webtest.events;

import org.slf4j.Logger;
import pl.myapp.webtest.config.qualifier.MyLogger;
import pl.myapp.webtest.events.qualifier.BlackCoffee;
import pl.myapp.webtest.events.qualifier.WhiteCoffee;
import pl.myapp.webtest.events.stuff.CupOfCoffee;

import javax.enterprise.context.RequestScoped;
import javax.enterprise.event.Event;
import javax.inject.Inject;
import javax.inject.Named;

/**
 * Created by IntelliJ IDEA.
 * User: kaafaar
 * Date: 16.05.11
 * Time: 22:27
 * To change this template use File | Settings | File Templates.
 */
@Named
@RequestScoped
public class CoffeeEventManagedBean {
    @Inject
	@MyLogger
    Logger logger;

    @Inject
    @WhiteCoffee
    private Event<CupOfCoffee> event;

    @Inject
    @BlackCoffee
    private Event<CupOfCoffee> eventBlackCoffee;

    public void coffeeCup() {
        logger.info("coffeCup");
        CupOfCoffee cupOfCoffee = new CupOfCoffee("Some name", 0.99f);
        event.fire(cupOfCoffee);
    }

    public void blackCoffee() {
        CupOfCoffee cupOfCoffee = new CupOfCoffee("Some black coffee name", 0.99f);
        logger.info("... and now black coffee");
        eventBlackCoffee.fire(cupOfCoffee);
    }
}
